home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
nfaphp48
< prev
next >
Wrap
Text File
|
1995-03-31
|
18KB
|
825 lines
NFAP (c) 1990
All rights Reserved
Don C Robinson
3812 Booth
Kansas City, KS 66103
(913)362-3969 Home
(816)854-5434 Work
This program is provided free of charge and can be distributed under the follow:
1) It is distributed unaltered, complete with document file included.
2) Also it has to be given freely. No charge or distribution fee, may be coll.
3) If used for commercial use, the company should contact me directly for perm.
The reason for the above distribution rules is simple. I provided the program .
NFAP - Nodal Format Analysis Program
for calculating the voltages of an AC Electronics Circuit using descrete compon.
Program overview:
Variables Used:
N= Number Nodes
F= Frequency
Three complex matrices are used:
A= N by N complex matrix, contains device loads
B= N by 1 complex matrix, contains current sources
C= N by 1 complex matrix, is the unknown voltages matrix
B=A*C
C=B/A To find the solution
Devices are added into the matrices as using the following formulas:
Resistor: R ohms
-> Ix
O-------------\/\/\/\/\-------------O
Node From Node To
m=1/R+0j
Capacitor: C farads
-> Ix
O-----------------|(----------------O
Node From Node To
m=0+2(pi)C(freq)j
Inductor: L Henry
-> Ix
O-----------------[Z]---------------O
Node From Node To
m=0+-1/(2(pi)L(freq))j
R+xj: R ohms + x=(L) Henry
-> Ix
O-------\/\/\/\/\/\------[Z]--------O
Node From Node To
m=1/R+-1/(2(pi)L(freq))j
Complex Value (m) is added or subtracted into matrix A as follows:
------------------------------------------------------------
Matrix A Row/Column |----------------Column----------------|
--------Row---------| Node Leaving | Node Entering |
--------------------|-------------------|------------------|
Node Leaving+ (From)| +m | -m |
Node Entering+ (To) | -m | +m |
------------------------------------------------------------
Current Source: I Angle Theta
-> Ix
O----------------(->)--------------O
Node From I Node To
------------------------------------------
Matrix B Row |One dimension matrix|
--------Row---------|----Column one------|
--------------------|--------------------|
Node Leaving+ (From)| -I |
Node Entering+ (To) | +I |
------------------------------------------
Vs+R
Voltage Source with Resistor in series: E Volts, R ohms
I=E/R
Add I the same as a current source and add R same as a resistor.
IcIs
Current Controlled Current Source:
Node Leaving Node Leaving
Control side Source Side
_______ _______
+ | | +
\ |
/ | |
R \ Ib (I) V I=B*Ib B=Beta=Control Value
/ | Ib=Current through R
\ |
- | | -
------- -------
Node Entering Node Entering
Control Side Source Side
m=B/r B=Control Value
Add m to Matrix A as follows and then add R to Matrix A same as a resistor.
------------------------------------------------------------
Matrix A Row/Column |----------------Column----------------|
--------Row---------| Source Nodes |
----Control Nodes---| Node Leaving | Node Entering |
--------------------|-------------------|------------------|
Node Leaving+ (From)| +m | -m |
Node Entering+ (To) | -m | +m |
------------------------------------------------------------
VcIs
Voltage Controlled Current Source:
Node Leaving Node Leaving
Control side Source Side
_______ _______
+ | | +
\ |
/ |
R \ Vx (I) I=gm(Vx) gm=Control factor
/ | Vx=Voltage across R
\ |
- | | -
------- -------
Node Entering Node Entering
Control Side Source Side
Add Control factor to matrix A as follows:
------------------------------------------------------------
Matrix A Row/Column |----------------Column----------------|
--------Row---------| Source Nodes |
----Control Nodes---| Node Leaving | Node Entering |
--------------------|-------------------|------------------|
Node Leaving+ (From)| +gm | -gm |
Node Entering+ (To) | -gm | +gm |
------------------------------------------------------------
Routines to NFAP for HP-48SX
Name Description
-------- ---------------------------------------------------
Begin Starts/Restarts program for AC Circuit Analysis.
DELv Purges all variables created by NFAP
Solv Solves for Voltages unknown and displays them in stk
VcIs Adds variables for Voltage Controlled I Source
R&Xj Adds variables for R+Xj device
Branch Subroutine that asks for Next Device
From Subroutine that asks for From and To nodes.
Brn Creates 'Dev' = Branch # + Device Type
Offm Blanks Custom menus
Menu Turns on Custom menus
Resis Adds variables for Resistor Device
Cap Adds variables for Capacitor Device
Inductor Adds variables for Inductor Device
Is Adds variables for Current Source
Vs&R Adds variables for Voltage Source + series Resistor
IcIs Adds variables for Current Controlled Current Source
Add Adds X to Matrix A using Fr and To for columns/Rows
Add2 Adds X to Matrix B using Fr and To for Rows
Add3 Adds X to Matrix A using Fr,Fr2,To,To2 for col/Rows
LblD Adds Device value + label to 'Dev' variable
LblF Adds Fr and To to 'Dev' variable
LblG Adds Fr2 and To2 to 'Dev' variable
Copyright Copyright message for NFAP
Variables Used:
Name Description
-------- ----------------------------------------------------
N Number of Nodes in circuit
F Frequency in Hz
A Matrix A - N by N complex matrix
B Matrix B - N by 1 complex matrix
C Matrix C - N by 1 complex Matrix
Bn Branch number (Number of Devices)
Dev Last Device/Current Device specs, helps keep track
of data entry.
CST Custom Menu list
X Complex variable used to add device to matrix
Fr From Node
To To Node
Fr2 From Node (control device)
To2 To Node (control device)
Y Complex Variable - Used when two devices are added.
-------------------------------------------------------------
Custom menu
[Resis] [ Cap ] [Induc] [ Is ] [VS&R ] [ICIS ]
NXT -> [VCIS ] [R&XJ ] [SOLV ] [BEGIN] [DELV ] [ ]
-------------------------------------------------------------
Running the program:
1) Go into NFAP Directory
2) Press [BEGIN] to Start or Restart the program.
3)Enter number of Nodes in Circuit, exclude reference node.
4) Enter Frequency
5) When prompted for Next Branch, select device from softkeys. For example if .
6) Repeat step 5 for each device in the circuit.
7) Select [SOLV] from the second level of softkeys to solve the matrix for the.
8) If your ready to begin another circuit go to step 2, If your ready to exit .
The end.
Now for an example:
Circuit:
[ Node 1 ] R2 [Node 2] R3 [Node 3]
[-------------------]--\/\/\/\/-[------]-\/\/\/\/-[------]
| | | 4 ohms | 3 ohms |
I R1 \ ) | )
Is (^) 1 / ) Inductor | Capacitor )
1<60| Meg \ ) .3 h = 1 uf .2 h )
| ohm / ) | Inductor )
| | | | |
[--------------------------------------------------------]
[ Reference Node ]
Start Program
[Begin]
|----------------------|
| NFAP (c) 1990 |
| |
| Nodal Format |
| Analysis Program |
| |
| By Don Robinson |
| |
|[ ] [ ] [ ] [ ] [ ][ ]|
|----------------------|
|----------------------|
| |
| Number Nodes? |
| |
| |
| < |
|[ ] [ ] [ ] [ ] [ ][ ]|
|----------------------|
Circuit has three nodes and a reference node.
Type
3 [ENTER]
|----------------------|
| |
| Frequency Hz? |
| |
| |
| < |
|[ ] [ ] [ ] [ ] [ ][ ]|
|----------------------|
Analysis the Circuit at 10,000 Hz
Type
10000 [ENTER]
|----------------------|
| NFAP (c) 1990 |
|Last: NONE |
| |
| |
| Branch Number 1 ? |
| |
| (Select Device) |
|[B] [C] [L] [I][V][IC]|
|----------------------|
Enter the current source.
Press Softkey
[ IS ]
|----------------------|
|Br=1 I<O | I<O=I Angle Theta
| |
|Current Source I<O? | I<O=I Angle Theta
| |
| < |
|[ ] [ ] [ ] [ ] [ ][ ]|
|----------------------|
Since the current source is a complex number 1 amp at phase 60 degrees. Enter r
Press
[Shift Left] ()
Next enter complex number
1 [Shift Right] [Angle Symbol] 60
So it looks something like
(1<60) < = Angle Symbol
Then type
[ENTER]
|----------------------|
|Br=1 I<O | I<O=I Angle Theta
|(1<60) : | Depends on Display Mode XYZ,R<Z
|Node L+.E-? |
| |
| < |
|[ ] [ ] [ ] [ ] [ ][ ]|
|----------------------|
Nodes L+.E-?
L=Leaving or From or +, and E=Entering or To or -.
The current source is Leaving node 0 and Entering Node 1.
Type in
0.1 [ENTER]
or type in
.1 [ENTER]
The program will flash that it is adding the current source into the matrix and.
|----------------------|
| NFAP (c) 1990 |
|Last: Br=1 I<O | Last device entered Branch 1, IS
|(I<60) :0:1 | 1 amp 60 deg from node 0 to 1
| |
| Branch Number 2 ? |
| |
| (Select Device) |
|[B] [C] [L] [I][V][IC]|
|----------------------|
Select
[Resis]
Resistance Value ohms?
Type
1 [EEX] 6 [ENTER]
Nodes L+.E-?
Type
1 [ENTER]
Doesn't matter on Resistor, Capacitor, Inductor or R=Xj what node goes in firstS
In the above case, any of the following inputs can be used:
1 [ENTER]
1.0 [ENTER]
.1 [ENTER]
0.1 [ENTER]
Next
Branch Number 3 ?
Press
[Induc]
Inductor Value?
Type
.3 [ENTER]
Nodes L+.E-?
Type
1 [ENTER]
Next
Branch Number 4 ?
Press
[Resis]
Resistance Value ohms ?
Type
4 [ENTER]
Nodes L+.E-?
Type
1.2 [ENTER] Node 2.1 would also work.
Next
Branch Number 5 ?
Press
[Cap]
Capacitor value?
Type
1 [EEX] 6 [+/-] [ENTER]
Nodes L+.E-?
Type
2 [ENTER]
Next
Branch Number 6 ?
Press
[Resis]
Resistance Value ohms ?
Type
3 [ENTER]
Nodes L+.E-?
Type
2.3 [ENTER] Node 3.2 would also work.
Branch Number 7 ?
Press
[Induc]
Inductor Value?
Type
.2 [ENTER]
Nodes L+.E-?
Type
3 [ENTER]
Branch Number 8 ?
At This point choose [SOLV] to calculate voltages for each node.
Type
[NXT] [SOLV]
[NXT] - Gets the second set of softkeys
[SOLV] - Softkey in custom menu. Solves for voltages
Solution for F=10000 Hz
V1: (16.443864352 <-15.8963542449)
V2: (15.9490964551 <-29.9869000426)
V3: (15.9490960007 <-29.973221683 )
Solution for F=60 Hz
V1: (46.18620388 <146.868)
V2: (46.02842193 <149.8078)
V3: (45.99203034 <152.0863 )
Bug reports and suggestions are welcome. This program is also available for th.
%%HP: T(3)A(D)F(.);
DIR
To 0
Fr 3
X
(0,-7.95774715457E-5)
CST { Resis Cap
Inductor Is Vs&R
IcIs VcIs R&Xj Solv
Begin DELv }
F 10000
Dev
"Br=7 Inductor
.2 h:3:0"
Bn 8
C
[[ (15.8150381166,-4.50391431966) ]
[ (13.8141456164,-7.97139000577) ]
[ (13.8160478582,-7.96809166731) ]]
B
[[ (.5,.866025403784) ]
[ (0,0) ]
[ (0,0) ]]
A
[[ (.250001,-5.30516476974E-5) (-.25,0) (0,0) ]
[ (-.25,0) (.583333333333,6.28318530718E-2) (-.333333333333,0) ]
[ (0,0) (-.333333333333,0) (.333333333333,-7.95774715457E-5) ]]
N 3
Begin
\<< CLLCD
" NFAP (c) 1990"
1 DISP
" Nodal Format"
3 DISP
" Analysis Program"
4 DISP
" By Don Robinson"
6 DISP { } MENU -40
CF 2 5
FOR j j CF
NEXT 1 SF
DELv CLEAR
"Number Nodes?" ""
INPUT OBJ\-> 'N' STO
{ N N } (0,0) CON
'A' STO { N 1 }
(0,0) CON DUP 'B'
STO 'C' STO 0 'Bn'
STO "NONE" 'Dev'
STO "Frequency Hz?"
"" INPUT OBJ\-> 'F'
STO Branch
\>>
DELv
\<< 'A' PURGE 'B'
PURGE 'C' PURGE 'F'
PURGE 'N' PURGE
'CST' PURGE 'Fr'
PURGE 'Y' PURGE 'X'
PURGE 'Bn' PURGE
'To' PURGE 'Dev'
PURGE '\Gb' PURGE
'To2' PURGE 'Fr2'
PURGE
IF 1 FC?C
THEN UPDIR
CLLCD
END
\>>
Solv
\<< CLLCD CLEAR
"Calculating" 1
DISP B A / 'C' STO
TEXT 0 STD 1 N
FOR j C j GET
"V" j \->STR + \->TAG
NEXT 4 ENG
\>>
VcIs
\<< "VcIs
" Brn
"
Voltage Control gm?"
+ "" INPUT OBJ\-> DUP
'X' STO "gm" LblD
"
Vx " + 3 SF From
LblF "
Is " + 3 SF
2 SF From LblG Add3
\>>
R&Xj
\<< "R+Xj
" Brn
"
Resistance Value \GW?"
+ "" INPUT OBJ\-> DUP
INV 'X' STO "\GW"
LblD
"
Impedance Value (Xj)?"
+ "" INPUT OBJ\-> DUP
X SWAP 2 * \pi \->NUM *
F * INV NEG R\->C 'X'
STO "Xj" LblD From
LblF Add
\>>
Branch
\<<
IF 4 FC?C
THEN CLLCD
" NFAP (c) 1990"
1 DISP "Last: " Dev
+ 2 DISP STD 1 'Bn'
STO+
" Branch Number "
Bn \->STR + " ?" + 5
DISP
" (Select Device)"
7 DISP Menu1 1 MENU
3 FREEZE
END
\>>
From
\<<
IF 3 FC?C
THEN "
" +
END
"Node L+.E-?" + ""
INPUT OBJ\-> DUP IP
IF 2 FS?
THEN 'Fr2'
ELSE 'Fr'
END STO FP N
LOG IP 1 + ALOG *
IF 2 FS?C
THEN 'To2'
ELSE 'To'
END STO
\>>
Brn
\<< Offm "Br=" Bn
\->STR + " " + SWAP +
DUP 'Dev' STO
\>>
Offm
\<< { } MENU
\>>
Menu1
\<< { Resis Cap
Inductor Is Vs&R
IcIs VcIs R&Xj Solv
Begin DELv } MENU
\>>
Resis
\<< "Resistor
"
Brn
"
Resistance Value \GW?"
+ "" INPUT OBJ\-> DUP
INV 0 R\->C 'X' STO
"\GW" LblD From LblF
Add
\>>
Cap
\<< "Capacitor
"
Brn
"
Capacitor Value?"
+ "" INPUT OBJ\-> DUP
0 SWAP F * 2 * \pi
\->NUM * R\->C 'X' STO
"f" LblD From LblF
Add
\>>
Inductor
\<< "Inductor
"
Brn
"
Inductor Value?"
+ "" INPUT OBJ\-> DUP
0 SWAP 2 * F * \pi
\->NUM * -1 SWAP /
R\->C 'X' STO "h"
LblD From LblF Add
\>>
Is
\<< "I\<)\Gh
" Brn
"
Current Source I\<)\Gh?"
+ "" INPUT OBJ\-> DUP
'X' STO "" LblD
From LblF Add2
\>>
Vs&R
\<< "Vs+R
" Brn
"
Voltage Source (E\<)\Gh)?"
+ "" INPUT OBJ\-> DUP
'X' STO "E" LblD
"
Resistance \GW ?" +
"" INPUT OBJ\-> DUP
INV DUP 'Y' STO X *
'X' STO \->STR "\GW:" +
Dev SWAP + DUP
'Dev' STO From LblF
DUP 4 SF Add2 Y 'X'
STO Add
\>>
IcIs
\<< "IcIs
" Brn
"
Resistance Value \GW?"
+ "" INPUT OBJ\-> DUP
INV 'Y' STO "\GW"
LblD
"
Contol factor (\Gb)?"
+ "" INPUT OBJ\-> DUP
'\Gb' STO "\Gb" LblD
"
R " + 3 SF From
LblF Y 0 R\->C 'X'
STO 4 SF Add Dev
"
Is " + 2 SF 3 SF
From LblG \Gb Y * 0
R\->C 'X' STO Add3
\>>
Add
\<< CLLCD 1 DISP
" Adding To Mat"
4 DISP 3 FREEZE
IF Fr 0 \=/
THEN A { Fr
Fr } GET X + A { Fr
Fr } ROT PUT 'A'
STO
END
IF Fr 0 \=/
THEN
IF To 0 \=/
THEN A { To
Fr } GET X - A { To
Fr } ROT PUT 'A'
STO A { Fr To } GET
X - A { Fr To } ROT
PUT 'A' STO
END
END
IF To 0 \=/
THEN A { To
To } GET X + A { To
To } ROT PUT 'A'
STO
END Branch
\>>
Add2
\<< CLLCD 1 DISP
" Adding To Mat"
4 DISP 3 FREEZE
IF Fr 0 \=/
THEN B Fr GET
X - B Fr ROT PUT
'B' STO
END
IF To 0 \=/
THEN B To GET
X + B To ROT PUT
'B' STO
END Branch
\>>
Add3
\<< CLLCD 1 DISP
" Adding To Mat"
4 DISP 3 FREEZE
IF Fr2 0 \=/
THEN
IF Fr 0 \=/
THEN A {
Fr2 Fr } GET X + A
{ Fr2 Fr } ROT PUT
'A' STO
END
IF To 0 \=/
THEN A {
Fr2 To } GET X - A
{ Fr2 To } ROT PUT
'A' STO
END
END
IF To2 0 \=/
THEN
IF Fr 0 \=/
THEN A {
To2 Fr } GET X - A
{ To2 Fr } ROT PUT
'A' STO
END
IF To 0 \=/
THEN A {
To2 To } GET X + A
{ To2 To } ROT PUT
'A' STO
END
END Branch
\>>
LblD
\<< SWAP \->STR Dev
SWAP + " " + SWAP +
":" + DUP 'Dev' STO
\>>
LblF
\<< Dev Fr \->STR +
":" + To \->STR + DUP
'Dev' STO
\>>
LblG
\<< Dev ":" + Fr2
\->STR + ":" + To2
\->STR + DUP 'Dev'
STO
\>>
Copyright
\<<
"V1.0 May 18,1990
(c) Copyright
Don C Robinson
(913)362-3969hm
(816)854-5243wk"
\>>
END